package com.sdkx.wear_os.adapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.sdkx.wear_os.R
import com.sdkx.wear_os.bean.MineBean
import com.sdkx.wear_os.databinding.LayoutMineItemBinding

/**
 * 我的
 */
class MineAdapter : BaseQuickAdapter<MineBean, DataBindingHolder<LayoutMineItemBinding>>() {
    override fun onBindViewHolder(
        holder: DataBindingHolder<LayoutMineItemBinding>,
        position: Int,
        item: MineBean?
    ) {
        holder.binding.run {
            item?.let { item ->
                if (item.icon != null) {
                    mineItemIv.visibility = View.VISIBLE
                    mineItemIv.setImageResource(item.icon)
                } else {
                    mineItemIv.visibility = View.GONE
                }
                mineItemTitle.text = item.title
                mineItemContent.text = item.content
            }
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): DataBindingHolder<LayoutMineItemBinding> {
        return DataBindingHolder<LayoutMineItemBinding>(R.layout.layout_mine_item, parent)
    }
}